# coding:utf8

from firefly.server.globalobject import netserviceHandle, GlobalObject, remoteserviceHandle, rootserviceHandle
from twisted.python import log

print "init gate!!"
@rootserviceHandle
def gate_handle_200(data):
    """
    我的孩子可以调用我暴露的此接口, 将详细传递给我
    :param data:
    :return:
    """

    print 'gate redirect game!!!'
    print data
    return GlobalObject().root.callChild("game", "game_handle_200", data) #  在此 我将消息传递给我的孩子 game


@rootserviceHandle
def forwarding_root(key, session_id, data={}):
    print "forwarding_root  key=", key

    return GlobalObject().root.callChildByName("game", "forwarding_remote", key, session_id, data)


@rootserviceHandle
def push_object(key, session_id, data={}):
    print "gate, push_object key=",key
    log.msg("gate, push_object key=%s"%key)
    GlobalObject().root.callChildByName("webnet_1", "push_object", key, session_id, data)